package cn.edu.neu.vmmigeval.cloud.policy;

import cn.edu.neu.vmmigeval.cloud.entity.Host;
import cn.edu.neu.vmmigeval.evaluation.loadevaluation.HostLoadEvaluation;

import java.util.LinkedList;
import java.util.List;

public abstract class MigratedHostPolicy {
	
	public List<Host> getOverHosts(List<Host> hosts){
		HostLoadEvaluation hle = new HostLoadEvaluation(hosts);
		hle.getFinal();
		List<Host> overUtilizedHosts = new LinkedList<Host>();
		for (Host host : hosts) {
			if (host.getActive()==0&&isHostOverUtilized(host)&&!host.isMigration()) {
				overUtilizedHosts.add(host);
				System.out.println("host score is :"+host.getScore());
			}
		}
		return overUtilizedHosts;
	}
	public List<Host> getUnderHosts(List<Host> hosts){
		HostLoadEvaluation hle = new HostLoadEvaluation(hosts);
		hle.getFinal();
		List<Host> underUtilizedHosts = new LinkedList<Host>();
		for (Host host : hosts) {
			if (host.getActive()==0&&isHostUnderUtilized(host)&&!host.isMigration()) {
				host.setLoadFlag(1);
				underUtilizedHosts.add(host);
			}
		}
		return underUtilizedHosts;
	}
	
	public abstract boolean isHostOverUtilized(Host host);
	public abstract boolean isHostUnderUtilized(Host host);
	

	

	
}
